package org.example.Test;

import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class Test6 {
    public static void main(String[] args) {
        File file = new File("C:\\Users\\12406\\Desktop\\业务work\\2024\\04\\客群下发\\智慧魔方\\标签文档.xlsx");
        byte[] fileContent;
        try (InputStream inputStream = new FileInputStream(file);
             ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
            byte[] buffer = new byte[1024];
            int length;
            while ((length = inputStream.read(buffer)) != -1) {
                outputStream.write(buffer, 0, length);
            }
            fileContent = outputStream.toByteArray();
        } catch (IOException e) {
            e.printStackTrace();
        }

//        MultipartFile multipartFile = new CommonsMultipartFile(fileContent) {
//            @Override
//            public String getName() {
//                return file.getName();
//            }
//
//            @Override
//            public String getOriginalFilename() {
//                return file.getName();
//            }
//
//            @Override
//            public String getContentType() {
//                return "application/octet-stream"; // You can change the content type based on the file type
//            }
//        };

    }
}
